package apk.cme.mm.interviewdemo.ui.activity

import android.os.Bundle
import apk.cme.mm.interviewdemo.R
import apk.cme.mm.interviewdemo.ui.fragment.PlaceholderFragment

/**
 * Descriptions：
 * <p>
 * Author：ChenME
 * Date：2019/1/23
 * Email：ibelieve1210@163.com
 */
class FragmentDemoActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_fragment_demo)

        initFragment()
    }

    private fun initFragment() {

        // 1. 通过 FragmentManager 获取到 FragmentTransaction 的实例
        val fragmentManager = supportFragmentManager
        val transaction = fragmentManager.beginTransaction()

        // 2. 创建 Fragment 实例，并将其添加到 FragmentTransaction 中
        val fPlaceholder = PlaceholderFragment()
        transaction.add(R.id.fl_placeholder,fPlaceholder,"fPlaceholder")

        // 3. 将 FragmentTransaction 提交
        transaction.commit()
    }
}